package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.WeeklySectorDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.WeeklySectorData;
import org.sixtynine.stock.service.WeeklySectorDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Thilan
 * 
 */

@Service
public class WeeklySectorDataServiceImpl implements WeeklySectorDataService {

	@Autowired
	private WeeklySectorDataDao weeklySectorDataDao;

	@Override
	public WeeklySectorData findById(int id) {
		return weeklySectorDataDao.findById(id);
	}

	@Override
	public void saveWeeklySectorData(WeeklySectorData weeklySectorData) {
		weeklySectorDataDao.saveWeeklySectorData(weeklySectorData);
	}

	@Override
	public void deleteWeeklySectorData(int id) {
		WeeklySectorData weeklySectorData = weeklySectorDataDao.findById(id);
		if (weeklySectorData != null) {
			weeklySectorDataDao.delete(weeklySectorData);
		}
	}

	@Override
	public List<WeeklySectorData> findWeeklySectorData(int id) {
		return weeklySectorDataDao.findWeeklySectorData(id);
	}

	@Override
	public List<org.sixtynine.stock.entity.WeeklySectorData> searchWeeklySectorData(
			int sectorId, Date fromDate, Date toDate, String orderBy,
			String orderByName) {

		return weeklySectorDataDao.searchWeeklySectorData(sectorId, fromDate,
				toDate, orderBy, orderByName);
	}

	@Override
	public Page<WeeklySectorData> searchWeeklySectorData(int sectorId,
			Date fromDate, Date toDate, String orderBy, String orderByName,
			GridPramDTO gridPramDTO) {
		return weeklySectorDataDao.searchWeeklySectorData(sectorId, fromDate,
				toDate, orderBy, orderByName, gridPramDTO);
	}

	@Override
	public void deleteWeeklySectorData(int sectorId, Date fromDate, Date toDate) {
		weeklySectorDataDao.deleteWeeklySectorData(sectorId, fromDate, toDate);
	}

}
